package me.shiqiang.im.consumer;

import com.aliyun.openservices.ons.api.Action;
import com.aliyun.openservices.ons.api.ConsumeContext;
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.MessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author cuishiqiang
 * @date 2017/12/17 下午7:09
 */
@Component("MsgConsumer")
public class MsgConsumer implements MessageListener {


    @Autowired
    Map<String, MsgListener> msgListenerMap;

    @Override
    public Action consume(Message message, ConsumeContext context) {
        return msgListenerMap.get(message.getTag()).consume(message, context);
    }
}
